Repository navigation
Conversation
getLocations sorted each source's positions with Array.prototype.toSorted. Hermes and other engines before ES2023 do not implement that method, so validate() and GraphQLError throw when an error cites more than one node. The position list is allocated inside getLocations and is not returned, so sorting it in place keeps the same locations and does not mutate caller input. Fixes graphql#5010
|
@eisen0419 is attempting to deploy a commit to the The GraphQL Foundation Team on Vercel. A member of the Team first needs to authorize it. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #5010.
getLocationssorted each source's positions withArray.prototype.toSorted(introduced in #4958). Engines without ES2023toSorted(such as Hermes in React Native, Safari < 16, and Chrome < 110) throw aTypeErrorduringvalidate()ornew GraphQLError(...)whenever an error spans two or more nodes.Because
positionsis freshly allocated insidegetLocationsviaAccumulatorMapand is never returned or shared with the caller, sorting it in place withpositions.sort((a, b) => a.position - b.position)preserves identical results without mutating caller input.Verification
src/language/__tests__/location-test.tsthat temporarily removesArray.prototype.toSorted(restoring the exact property descriptor infinally) and confirmsgetLocationsresolves unsorted positions without mutating frozen caller input.npm run testonly:cover(100% lines / branches / functions)npm run lint,npm run check:ts,npm run check:deno,npm run prettier:check,npm run testonly:examples